<?php
/**
 * 模块启动文件
 */
namespace addons\sign;
use addons\sign\controllers\Index;
use system\Addon;
use system\MyError;

class Sign extends Addon {
    public function getName()
    {
        return 'sign';
    }

    public function getVersion()
    {
        return '1.0.0';
    }

    public function getAuthor()
    {
        return 'Colin';
    }

    public function getDesc()
    {
        return '提供系统签到功能';
    }

    public function install()
    {
    	// 检查是否有安装redis扩展
		if(!extension_loaded('redis')){
			throw new MyError('未安装Redis扩展');
		}
		// 检查是否有安装用户模块
		if (!addonIs('member')){
			throw new MyError('请先安装member模块');
		}
		return true;
    }

    public function uninstall() {
		return true;
	}

	public function onInitMenu(&$data = []){
    	foreach ($data as $key => &$val){
    		if ($val['name'] == 'user'){
    			// 会员板块
				$item = ['name' => 'list', 'title' => '签到列表', 'auth_name' => Index::class, 'action' => 'index' , 'jump' => '---sign/index'];
				array_push($val['list'] , $item);
			}
		}
	}
}